package com.aaa.outbound.mapper;

import com.aaa.entity.outbound.PickDetail;
import com.aaa.entity.outbound.PicktaskDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author aaa
 * @since 2020-12-03
 */
@Mapper
@Component
public interface PickDetailMapper extends BaseMapper<PickDetail> {
    @Select("select pd.* from o_picktask_detail pd \n" +
            "join o_picktask_outorder po on pd.pid=po.outorderid \n" +
            "join o_picktask pt on pt.id=po.picktaskid \n" +
            "join o_pick p on p.picktaskno=pt.picktaskno\n" +
            "where p.pickno=#{pickno}")
    List<PicktaskDetail> selectPicktaskDetailByPickno(String pickno);
    @Select("select pd.* from o_pick_detail pd\n" +
            "join o_pick p on pd.pid=p.id\n" +
            "join o_picktask pt on p.picktaskno=pt.picktaskno\n" +
            "join o_picktask_outorder po on po.picktaskid=pt.id\n" +
            "where po.outorderno=#{outorderno}")
    List<PickDetail> selectPickDetailByOutorderno(String outorderno);

    @Select("select pd.* from o_pick_detail pd\n" +
            "join o_pick p on p.id=pd.pid\n" +
            "where p.pickno=#{pickno}")
    List<PickDetail> selectPickDetailByPickno(String pickno);

    @Select("select po.outorderid from o_picktask_outorder po\n" +
            "join o_picktask pt on pt.id=po.picktaskid\n" +
            "join o_pick p on p.picktaskno=pt.picktaskno\n" +
            "where p.pickno=#{pickno}")
    Long selectOutorderIdByPickno(String pickno);

    @Select("select pd.commoditybar,pd.commodityname from o_picktask_detail pd\n" +
            "join o_picktask_outorder po on po.outorderid=pd.pid\n" +
            "join o_picktask p on p.id=po.picktaskid\n" +
            "where p.picktaskno=#{picktaskno}")
    List<PicktaskDetail> searchCommodityByPicktaskno(String picktaskno);

    @Select("select pd.locatorcode,pd.locatorname from o_picktask_detail pd\n" +
            "join o_picktask_outorder po on po.outorderid=pd.pid\n" +
            "join o_picktask p on p.id=po.picktaskid\n" +
            "where p.picktaskno=#{picktaskno} and pd.commoditybar=#{commoditybar}")
    List<PickDetail> searchLocatorByCommodity(String picktaskno,String commoditybar);
}
